package com.museum.controller;


import com.alibaba.fastjson.JSONObject;
import com.museum.base.BaseApiService;
import com.museum.base.BaseResponse;
import com.museum.controller.APi.DepLogAPI;
import com.museum.entity.DO.DepLog;
import com.museum.entity.DTO.DepLogCol;
import com.museum.service.impl.DepLogServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Ahm
 * @since 2021-03-13
 */
@RestController
@RequestMapping("/dep-log")
public class DepLogController extends BaseApiService<JSONObject> implements DepLogAPI {

    @Autowired
    private DepLogServiceImpl service;

    public BaseResponse<JSONObject> addDepLog(DepLog depLog, HttpServletRequest request) {
        int result = service.addDepLog(depLog,request);
        if (result>0){
            return  setResultSuccess("添加成功");
        }else {
            return  setResultError("添加失败");
        }

    }

    public BaseResponse<JSONObject> getAllDepLogByPage(long current, long limit, DepLogCol depLog) {
                JSONObject json = service.getAllDepLogByPage(current,limit,depLog);
        return setResultSuccess(json);
    }
//
    public BaseResponse<JSONObject> deleteLogById(Integer id) {
        int result = service.deleteDepLogById(id);
        if (result>0){
            return setResultSuccess("删除成功");
        }else {
            return setResultError("删除失败");
        }
    }

}

